package com.he.listener;

import com.he.entity.Hotel;
import com.he.event.EventListener;
import com.he.event.constact.EventConstact;
import com.he.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;

public class HotelEventListener implements EventListener<Hotel> {

    @Autowired
    private ICityService cityService;

    /**
     * 处理"酒店新增"事件
     * @return
     */
    @Override
    public String getEventType() {
        return EventConstact.EVENT_HOTEL_INSERT;
    }

    /**
     * 实际的触发方法
     * @param msg
     */
    @Override
    public void eventHandler(Hotel msg) {
        System.out.println("城市服务，接收到酒店新增事件，" + msg);
        cityService.updateCityHNumber(msg.getCid(), 1);
    }


}
